package com.example.springblog.service;

import com.example.springblog.mapper.BlogInfoMapper;
import com.example.springblog.mapper.UserInfoMapper;
import com.example.springblog.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private BlogInfoMapper blogInfoMapper;

    public UserInfo queryByName(String name) {
        return userInfoMapper.queryByName(name);
    }

    public UserInfo queryById(Integer id) {
        return userInfoMapper.queryById(id);
    }

    public UserInfo getAuthorInfoByBlogId(Integer blogId) {
        Integer userId = blogInfoMapper.getUserIdByBlogId(blogId);
        return userInfoMapper.queryById(userId);
    }
}
